package net.sareweb.acab.session;

import net.sareweb.acab.entity.*;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;

@Name("commentonsuggestionHome")
public class CommentonsuggestionHome extends EntityHome<Commentonsuggestion> {

	@In(create = true)
	SuggestioninfoHome suggestioninfoHome;
	@In(create = true)
	UserHome userHome;

	public void setCommentonsuggestionIdCommentOnSuggestion(Integer id) {
		setId(id);
	}

	public Integer getCommentonsuggestionIdCommentOnSuggestion() {
		return (Integer) getId();
	}

	@Override
	protected Commentonsuggestion createInstance() {
		Commentonsuggestion commentonsuggestion = new Commentonsuggestion();
		return commentonsuggestion;
	}

	public void load() {
		if (isIdDefined()) {
			wire();
		}
	}

	public void wire() {
		getInstance();
		Suggestioninfo suggestioninfo = suggestioninfoHome.getDefinedInstance();
		if (suggestioninfo != null) {
			getInstance().setSuggestioninfo(suggestioninfo);
		}
		User user = userHome.getDefinedInstance();
		if (user != null) {
			getInstance().setUser(user);
		}
	}

	public boolean isWired() {
		if (getInstance().getSuggestioninfo() == null)
			return false;
		if (getInstance().getUser() == null)
			return false;
		return true;
	}

	public Commentonsuggestion getDefinedInstance() {
		return isIdDefined() ? getInstance() : null;
	}

}
